﻿@using ECSE6770.Models
@model EditProfileModel
@{
    string[] roles = Roles.GetAllRoles();
    HashSet<string> userRoles = new HashSet<string>(Roles.GetRolesForUser(Model.UserName));
}

@helper WriteCheckBox(string name, bool selected, bool disabled)
{
    <input type="checkbox" id="role_@(name)" value="@name" name="EditedRoles" @if (selected) { <text>checked="checked" </text> } @if (disabled) { <text>disabled="disabled" }</text> } />
    <label for="role_@(name)">@name</label>
}
<h4>User Roles</h4>
<ul class="roleSelect">
    @foreach (var role in roles.Select(r => new RoleInfo(r, userRoles.Contains(r))).OrderBy(r => r.RoleName))
    {
        bool disabled = role.RoleName == "Admin" && ViewBag.IsSuperAdmin == false;
        <li>@WriteCheckBox(role.RoleName, role.IsMember, disabled)</li>
    }
</ul>